<?php if (!defined('THINK_PATH')) exit(); /*a:2:{s:62:"C:\xampp\htdocs\gyrjy/application/admin\view\single\index.html";i:1534256479;s:63:"C:\xampp\htdocs\gyrjy/application/admin\view\single\single.html";i:1534256479;}*/ ?>
<?php $namespace = ns(); ?>
<div class="box" id="<?php echo $namespace; ?>_box"></div>
<script>
    Namespace.register("EBCMS.<?php echo $namespace; ?>");
    $(function(){
        EBCMS.<?php echo $namespace; ?>.queryParams = {
            page:1,
            rows:50,
            order:{
                'sort':'desc',
                'id':'asc',
            },
            model:'admin/single',
        };
        EBCMS.<?php echo $namespace; ?>.refresh = function refresh(p){
            if (p) {
                $.each(p, function(index, val) {
                    if (typeof val == 'object') {
                        EBCMS.<?php echo $namespace; ?>.queryParams[index] = $.extend(EBCMS.<?php echo $namespace; ?>.queryParams[index], p[index]);
                        delete p[index];
                    };
                });
                $.extend(EBCMS.<?php echo $namespace; ?>.queryParams, p);
            };
            EBCMS.CORE.api({
                queryParams:EBCMS.<?php echo $namespace; ?>.queryParams,
                group:'group',
                tpl:'<?php echo $namespace; ?>-table',
                target:'#<?php echo $namespace; ?>_box',
                compileAfter:function(){
                    $('.hide-bar').parent().height($('.hide-bar').parent().height()).css('overflow','hidden');
                    $('.hide-bar').parent().hover(function() {
                        $(this).find('.hide-bar').show();
                        $(this).find('.hide-bar').animate({bottom:$(this).find('.hide-bar').height()});
                    }, function() {
                        $(this).find('.hide-bar').animate({bottom:'0px'});
                    });

                    $('#<?php echo $namespace; ?>_box').find('.input_sort').focus(function(){
                        EBCMS.<?php echo $namespace; ?>.sortvalue = $(this).val();
                    }).blur(function(){
                        var $this = $(this);
                        if ($this.val() != EBCMS.<?php echo $namespace; ?>.sortvalue) {
                            EBCMS.ACT.togglefield('<?php echo url('admin/single/resort'); ?>',$this.data('id'),$this.val(),'<?php echo $namespace; ?>','resort');
                        };
                    });

                }
            });
        };
        EBCMS.<?php echo $namespace; ?>.edit = function edit(id){
            EBCMS.CORE.get({
                url:'<?php echo url('admin/single/edit'); ?>',
                queryParams:{
                    id:id,
                },
                target:'#lgModal .modal-content',
            });
        };
        EBCMS.<?php echo $namespace; ?>.add = function add(group){
            EBCMS.CORE.get({
                url:'<?php echo url('admin/single/add'); ?>',
                queryParams:{
                    group:group,
                },
                target:'#lgModal .modal-content',
            });
        };
        EBCMS.<?php echo $namespace; ?>.refresh();
    });
</script>

<script id="<?php echo $namespace; ?>-table" type="text/html">
    <br>
    <div class="col-md-12">
        <button class="btn btn-primary" onclick="EBCMS.<?php echo $namespace; ?>.add();">添加</button>
        <hr>
        <div class="alert alert-danger">
            <p>单页功能是对内容模块的一个补充。支持自定义扩展，支持自选模板，支持自定义路径。用单页功能可以制作出独特的页面。</p>
        </div>
    </div>
    <div class="col-md-12">
        [[each groups as data group]]
        <div class="panel panel-default">
            <div class="panel-heading">[[group]]</div>
            <div class="panel-body">
                [[include '<?php echo $namespace; ?>-table-item' data]]
            </div>
            <div class="panel-footer">
                <button class="btn btn-primary btn-sm" onclick="EBCMS.<?php echo $namespace; ?>.add('[[group]]');">添加</button>
            </div>
        </div>
        [[/each]]
    </div>
</script>
<style>
    .hide-bar button{
        margin: 5px auto;
    }
</style>
<script id="<?php echo $namespace; ?>-table-item" type="text/html">
    [[each rows as v n]]
        <div class="thumbnail" style="width:180px;float:left;margin:10px;cursor: pointer;">
            <div style="width:100%;height:100px;background:#FF630E;">
                <div style="width:100%;height:100px;line-height:100px;color:#fff;font-size:30px;text-align:center;overflow:hidden;">[[v.title]]</div>
                <div class="hide-bar" >
                    <div style="padding:5px;">
                        [[if v.status==1]]
                        <button class="btn btn-default btn-xs" onclick="EBCMS.ACT.status('<?php echo url('admin/single/status'); ?>','[[v.id]]','0','<?php echo $namespace; ?>');">已审</button>
                        [[else]]
                        <button class="btn btn-warning btn-xs" onclick="EBCMS.ACT.status('<?php echo url('admin/single/status'); ?>','[[v.id]]','1','<?php echo $namespace; ?>');">未审</button>
                        [[/if]]
                        <button class="btn btn-default btn-xs" onclick="EBCMS.<?php echo $namespace; ?>.edit('[[v.id]]');">编辑</button>
                        <button class="btn btn-default btn-xs" onclick="EBCMS.ACT.del('<?php echo url('admin/single/delete'); ?>','[[v.id]]','<?php echo $namespace; ?>');">删除</button>
                        <button class="btn btn-default btn-xs" onclick="EBCMS.CORE.recommend({
                            model:'single/single',
                            id:'[[v.id]]',
                            thumb:'[[v.thumb]]',
                            url:'[[v.ebcms_url]]',
                            title:'[[v.shorttitle | escape]]',
                            description:'[[v.description | escape]]'
                            });">推送</button>
                        <a href="<?php echo url('index/api/gourl'); ?>?url=[[encodeURIComponent('index/single/index?id=')]][[v.id]]" class="btn btn-default btn-xs" target="_blank">查看</a>
                    </div>
                </div>
            </div>
            <!-- <br> -->
            <div style="height:5px;clear:both;"></div>
            <div class="input-group">
              <span class="input-group-addon">排序</span>
              <input type="text" class="form-control input-sm input_sort" data-id="[[v.id]]" value="[[v.sort]]" placeholder="越大越靠前">
            </div>
        </div>
    [[/each]]
</script>